"""
公共响应模型
"""
from typing import Generic, TypeVar, Optional, Any
from pydantic import BaseModel, Field


DataT = TypeVar("DataT")


class ResponseModel(BaseModel, Generic[DataT]):
    """统一响应模型"""
    code: int = Field(default=200, description="响应码")
    message: str = Field(default="success", description="响应消息")
    data: Optional[DataT] = Field(default=None, description="响应数据")


class PaginationParams(BaseModel):
    """分页参数"""
    page: int = Field(default=1, ge=1, description="页码")
    page_size: int = Field(default=10, ge=1, le=100, description="每页数量")


class PaginatedResponse(BaseModel, Generic[DataT]):
    """分页响应模型"""
    total: int = Field(description="总数")
    page: int = Field(description="当前页码")
    page_size: int = Field(description="每页数量")
    items: list[DataT] = Field(description="数据列表")
    total_pages: int = Field(description="总页数")


class HealthCheckResponse(BaseModel):
    """健康检查响应"""
    status: str = "healthy"
    app_name: str
    version: str
    environment: str

